package service

import (
	"aglaia/internal/model"
	"errors"
)

type AuthRequest struct {
	AppKey    string `json:"username"`
	AppSecret string `json:"password"`
}

func (svc *Service) CheckAuth(param *AuthRequest, loginIp string) (model.Auth, int, error) {
	auth, surplus, err := svc.dao.GetAuth(param.AppKey, param.AppSecret, loginIp)
	if err != nil {
		return auth, surplus, err
	}

	if auth.Id > 0 {
		return auth, surplus, nil
	}

	return auth, surplus, errors.New("auth info does not exist")
}
